package com.globant.tab;

import android.app.Dialog;
import android.os.Bundle;
import android.view.Window;
import android.widget.ListView;
import android.widget.TextView;

import com.globant.adapter.BattleAdapter;
import com.globant.bean.PlayerBean;
import com.globant.common.MockData;
import com.globant.tab.R;

public class BattleTabActivity extends CommonTabActivity {

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_battle_tab);
        
		BattleAdapter adaptador = new BattleAdapter(this, MockData.createMockPlayers());

		ListView battleList = (ListView) findViewById(R.id.battleList);
		battleList.addHeaderView(createHeader());
		battleList.setAdapter(adaptador);
        
    }   
    
    
    private void populateDialog(Dialog v) {
 	   
 	   PlayerBean you = MockData.createMockPlayer();
 	   PlayerBean opponent = MockData.createMockPlayers().get(0);
 	   
 	   TextView opponentName = (TextView) v.findViewById(R.id.opponentName);
 	   opponentName.setText(opponent.getName());
 	   
 	   TextView youHenchmen = (TextView) v.findViewById(R.id.youHenchmen);
 	   youHenchmen.setText(String.valueOf(you.getHenchmen()));
 	   
 	   TextView opponentHenchmen = (TextView) v.findViewById(R.id.opponentHenchmen);
 	   opponentHenchmen.setText(String.valueOf(opponent.getHenchmen()));
 	   
 	   
 	   TextView youAttack = (TextView) v.findViewById(R.id.youAttack);
 	   youAttack.setText(String.valueOf(you.getAttackPoints()));
 	   
 	   TextView opponentDefense = (TextView) v.findViewById(R.id.opponentDefense);
 	   opponentDefense.setText(String.valueOf(opponent.getDefensePoints()));
    }
    
    @Override
	public Dialog onCreateDialog(int id) {
		Dialog dialog = new Dialog(this);
		dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
		dialog.setContentView(R.layout.battle_dialog);
		populateDialog(dialog);
		return dialog;
	}
}
